define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'jvisiting/index' + location.search,
                    add_url: 'jvisiting/add',
                    edit_url: 'jvisiting/edit',
                    del_url: 'jvisiting/del',
                    multi_url: 'jvisiting/multi',
                    table: 'visiting',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {field: 'id', title: __('序号'),operate:false},
                        {field: 'name', title: __('Name'),operate:false},
                        {field: 'mobile', title: __('Mobile'),operate:false},
                        {field: 'venue', title: __('Venue'),searchList: {"A": __('北山街馆区'),"B": __('栖霞岭馆区')}},
                        {field: 'company', title: __('Company'),operate:false},
                        {field: 'department', title: __('政治面貌'),operate:false},
                        {field: 'position_type', title: __('单位类型'),operate:false},
                        {field: 'views', title: __('Views'),operate:false},
                        {field: 'actual_views', title: __('Actual_views'),operate:false},
                        {field: 'explain', title: __('讲解'),operate:false},
                        {field: 'day', title: __('Day'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'between_time', title: __('Between_time'),operate:false},
                        {field: 'user.nickname', title: __('讲解员'),operate:false},
                        {field: 'status', title: __('预约状态'),searchList: { "1": __('预约中'), "2": __('完成评价'), "3": __('取消预约'), "4": __('完成参观'), "5": __('特殊预留'),"6": __('未参观')}},
                        {field: 'code', title: __('预约码'),operate:false},
                        {field: 'type', title: __('预约类型'),operate:false},
                        {field: 'actual_time', title: __('到达时间') ,operate:false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});